package gui;

import graphics.Universe;
import gui.tools.ActionHandler;
import gui.tools.Menu;
import gui.tools.ToolBar;

import java.awt.BorderLayout;

import javax.swing.JFrame;

import com.sun.j3d.utils.universe.SimpleUniverse;

/**
 * JFrame of which is created at startup
 * 
 * @author: Eirik Vigeland
 * @version: %I%, %G%
 */
public class Frame extends JFrame {

	private static final long serialVersionUID = 1L;
	private ActionHandler ac;
	private Universe universe;
	private ToolBar toolBar;
	
	/**
	 * Constructor of the frame, setting up the Menu, Toolbar and the Canvas3D.
	 */
	public Frame() {
		setTitle("GeoMag Simulator v0.1");
		setSize(800, 600);
		setLayout(new BorderLayout());
		/*
		 * TODO: Create ComponentListener for proper close-operation with System.exit and Dispose.
		 */
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		ac = new ActionHandler(this);
		universe = new Universe(SimpleUniverse.getPreferredConfiguration());
		add(universe, BorderLayout.CENTER);
		ac.getAdditional();
		Menu menu = new Menu(ac);
		toolBar = new ToolBar(ac);
		setJMenuBar(menu);
		add(toolBar, BorderLayout.WEST);
		setVisible(true);
	}
	
	/**
	 * Returns the Universe
	 * 
	 * @return Universe
	 */
	public Universe getUniverse() {
		return universe;
	}
}
